(function() {
	init();
	function init(){
		setDiv();
		showBox("您已经分享过，请不要重复分享，谢谢！",true);
	}
	function setDiv(){
		var bookWrapper = document.createElement("div");
		bookWrapper.setAttribute("id","bookWrapper");
		setPosition(bookWrapper);
		bookWrapper.innerHTML = "<div id='bookMain' style='background:#036EB8;z-index:9999;padding:10px;display:none;'><div id='bookContent' style='border:solid 1px #A2C3E7;padding:5px;background:#fff;color:red;font-weight:bold;'></div></div>";
		document.body.appendChild(bookWrapper);
	}
	function setPosition(obj){
		var p = winSize();
		obj.style.position = "absolute";
		obj.style.left = ((p.width-290)/ 2) + 'px';
		obj.style.top  = (p.height / 2 - 60) + 'px';
	}
	function showBox(msg,close){
		if($("bookMain").style.display == 'block'){
			return;
		}
		$("bookMain").style.display = 'block';
		 var msgNode = document.createTextNode(msg);
        $("bookContent").innerHTML = "";
        $("bookContent").appendChild(msgNode);

        if (close) {
            setTimeout(closeBox, 2000);
         }  
	}
	function closeBox(){
		$('bookWrapper').parentNode.removeChild($('bookWrapper'));
	}
	function winSize(){
		var winWidth = 0;
		var winHeight = 0;
		
		//获取窗口宽度
		if (window.innerWidth)
		   winWidth = window.innerWidth;
		else if ((document.body) && (document.body.clientWidth))
		   winWidth = document.body.clientWidth;
		//获取窗口高度
		if (window.innerHeight)
		   winHeight = window.innerHeight;
		else if ((document.body) && (document.body.clientHeight))
		   winHeight = document.body.clientHeight;
		//通过深入Document内部对body进行检测，获取窗口大小
		if (document.documentElement && document.documentElement.clientHeight && 
		    document.documentElement.clientWidth)
		{
		   winHeight = document.documentElement.clientHeight;
		   winWidth = document.documentElement.clientWidth;
		}
		return {width:parseInt(winWidth,10),height:parseInt(winHeight,10)};
	}
	function $(name){
		return document.getElementById(name);  
	}
})();